package com.hbnu.system.controller;

import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.entity.Hxxk;
import com.hbnu.system.service.HxxkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 横向科技类别(Hxxk)表控制层
 *
 * @author makejava
 * @since 2024-12-20 14:49:15
 */
@RestController
@RequestMapping("/hxxk")
@Api(tags = "横向-学科分类模块")
public class HxxkController {
    /**
     * 服务对象
     */
    @Resource
    private HxxkService hxxkService;

    @ApiOperation("横向科技学科分类添加")
    @PostMapping("/addHxxk")
    public Rest<Boolean> addHxxk(@RequestBody Hxxk hxxk){
        boolean add = hxxkService.addHxxk(hxxk);
        return add ? Rest.success():Rest.failed();
    }

    @ApiOperation("获取横向科技学科分类列表")
    @GetMapping("/getHxxk")
    public Rest<List<Hxxk>> getProjectcates(){
        List<Hxxk> projectcateList = hxxkService.getHxxkList();
        return Rest.success(projectcateList);
    }

    @ApiOperation("横向科技学科分类-修改")
    @PostMapping("/updateHxxk")
    public Rest<Boolean> updateHxxk(@RequestBody Hxxk hxxk){
        boolean update = hxxkService.updateHxxk(hxxk);
        return update ? Rest.success() : Rest.failed();
    }

    @ApiOperation("横向科技项目类别-删除")
    @GetMapping("/deleteHxxk")
    public Rest<Boolean> deleteHxxk(String ID){
        boolean delete = hxxkService.deleteHxxk(ID);
        return delete ? Rest.success() : Rest.failed();
    }

    //根据学科名字进行查询
    @ApiOperation("根据横向科技学科名字进行查询")
    @GetMapping("/getHxxkByName")
    public Rest<List<Hxxk>> getHxxkByName(String Name){
        List<Hxxk> hxxks= hxxkService.getByHxxkName(Name);
        return Rest.success(hxxks);
    }
}

